package tjs.study.notes.eureka.clienta.user.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tjs.study.notes.eureka.clienta.user.UserApplication;
import tjs.study.notes.eureka.clienta.user.service.feign.OrederFeignService;
import tjs.study.notes.eureka.clienta.user.service.restTemplate.OrederRestTemplateService;

/**
 * Created by Nicky.Tang on 2021/10/31 4:51 下午
 *
 * @since 02.12.10
 */
@Service
public class UserService {
    private static final Logger logger = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private OrederRestTemplateService orederRestTemplateService;
    @Autowired
    private OrederFeignService orederFeignService;

    public String pay(String userId) {
        StringBuilder stepBui = new StringBuilder();
        logger.warn("【user微服务.{}】1. 获取会员信息", UserApplication.INSTANCE_ID);
        stepBui.append(MessageFormatter.format("【user微服务.{}】1. 获取会员信息", UserApplication.INSTANCE_ID).getMessage()).append("\n\r");
        orederRestTemplateService.newOrder(userId,stepBui);
        return stepBui.toString();
    }

    public String payFeign(String userId, Integer sleepTime) {
        StringBuilder stepBui = new StringBuilder();
        logger.warn("【user微服务.{}】1. 获取会员信息", UserApplication.INSTANCE_ID);
        stepBui.append(MessageFormatter.format("【user微服务.{}】1. 获取会员信息", UserApplication.INSTANCE_ID).getMessage()).append("\n\r");
        orederFeignService.newOrder(userId, sleepTime, stepBui);
        return stepBui.toString();
    }
}
